<?php
/**
 * Created by PhpStorm.
 * Project: Parser Exist
 * File:    IEClass.php
 * Date:    18.07.13
 * Time:    10:03
 * User:    azzaro.max@gmail.com
 */


define('READYSTATE_COMPLETE', 4);


class browser
{
    public $ie = null;

    public function __construct()
    {
        $this->__initie();
    }

    private function __initie($left = 0, $top = 0, $width = 900, $height = 900, $visible = 1)
    {
        $this->ie = new COM("InternetExplorer.Application", null, CP_UTF8);
        $this->ie->left = $left;
        $this->ie->top = $top;
        $this->ie->width = $width;
        $this->ie->height = $height;

        $this->ie->menubar = 1;

        $this->ie->toolbar = 1;
        $this->ie->statusbar = 1;
        $this->ie->visible = $visible;
        $this->ie->silent = true;
    }

    public function navigate($url)
    {
        $this->ie->navigate($url);
        $this->wait();
    }


    public $dom;
    public $document;
    private function wait($sec = 0)
    {
        while ($this->ie->Busy) ;
        while ($this->ie->ReadyState != READYSTATE_COMPLETE)
        {
            //print $this->ie->ReadyState. "\n";
        }
        $this->document = $this->ie->Document;
    }

    public function __destruct()
    {
        $this->ie->Quit();
    }
}
